package com.xingkeduo.dto;

import com.xingkeduo.pojo.enums.CommentStar;
import com.xingkeduo.pojo.table.Comments;
import com.xingkeduo.pojo.table.Labels;
import lombok.Data;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 个人中心 评价详情
 */
@Data
public class QueryUserCenterResponseDto {

    //手艺人名称
    private String adminName;


    //手艺人头像
    private String adminImg;

    //店铺名称
    private String storeName;

    //服务评分
    private CommentStar commentStar;


    //评价内容（已过滤
    private String comment;


    //是否匿名
    private Boolean anonymous;

    /**
     * 评价标签
     */
    private String[] judgementLabels;

    /**
     * 图片列表
     */
    private String[] pics;

    List<LabelsResponseDto> labels;

    public void covert(Comments comments,List<LabelsResponseDto> labelsList, String adminId){
        String labes = comments.getLabels();
        if(StringUtils.isNotEmpty(comments.getPicIds())){
            this.pics = comments.getPicIds().split(",");
        }

        if(StringUtils.isNotEmpty(adminId)){
            this.adminImg = adminId;
        }

        if(StringUtils.isNotEmpty(labes) && !labelsList.isEmpty()){
            labelsList.forEach(LabelsResponseDto -> LabelsResponseDto.setIsShow(labes.indexOf(String.valueOf(LabelsResponseDto.getId()))>=0?1:0));
            this.labels = labelsList;
        }

    }


}
